package com.sky.mapper;

import com.sky.entity.SetmealDish;
import com.sky.vo.DishItemVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SetmealDishMapper {

    /*
    * 根据菜品id查询该菜品的套餐信息
    * */
    List<Long> getByIds(List<Long> ids);

    /*
    * 上传套餐-菜品信息
    * */
    void insertBatch(List<SetmealDish> setmealDishes);

    /*
    * 根据id查询套餐对应菜品信息
    * */
    @Select("select * from setmeal_dish where setmeal_id=#{setmealId}")
    List<SetmealDish> selsctBySetmealId(Long setmealId);

    /*
    * 根据setmealId删除数据
    * */
    @Delete("delete from setmeal_dish where setmeal_id=#{setmealId}")
    void deleteBySetmealId(Long setmealId);

    /*
    * 根据setmealIds删除数据
    * */
    void deleteBySetmealIds(List<Long> setmealIds);

    /*
    * 根据套餐id查询对应菜品中起售状态为禁售的数量
    * */
    @Select("select count(*) from setmeal_dish s left outer join dish d " +
            "on s.dish_id = d.id  where setmeal_id=#{setmealId} and d.status=0 ")
    Long selsctStatusNumberById(Long setmealId);

    /*
    * 根据套餐id查询对应的菜品数据
    * */
    List<DishItemVO> selsctDishItem(Long setmealId);
}
